package com.dpj.seckill.controller;

import com.dpj.seckill.service.TUserService;
import com.dpj.seckill.vo.LoginVo;
import com.dpj.seckill.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.xml.ws.Response;

@Slf4j
@RequestMapping("/login")
@Controller
public class LoginController {

    @Autowired
    private TUserService userService;

    //跳转到登录页
    @RequestMapping("toLogin")
    public String toLogin(){

        String a="zhang三";

        return "login";
    }

    //登录

    @ResponseBody
    @RequestMapping("doLogin")
    public RespBean doLogin(@Valid LoginVo loginVo, HttpServletRequest request, HttpServletResponse response){
        log.info("{}",loginVo);
        return userService.doLogin(loginVo,request,response);
    }
}

